﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kooboo.HtmlFunc.Providers;

namespace Kooboo.CMS.SiteConverter.Parser.WebForm
{
    public class MenuParser : ParserBase, IParser<IMenu>
    {
        #region IParser<IMenu> Members

        public void Parse(IMenu obj)
        {
            var loopStart = @"
    <%foreach (var item in MenuHelper.Top())
    {
        if (item.Navigation.Show)
        {%>";
            var classFormat = "<%:MenuHelper.IsCurrent(item) ? \"current\" : \"\"%>";
            var linkFormat = "<%:Html.FrontHtml().PageLink(item.LinkText, item.FullName)%>";
            var linkHref = @"<%:Url.FrontUrl().PageUrl(item.FullName)%>";
            var linkText = @"<%:item.LinkText%>";
            var loopEnd = @"
        <%}
    }%>";
            Razor.MenuParser.Format(obj, loopStart, loopEnd, classFormat, linkFormat, linkHref, linkText);
        }

        #endregion
    }
}
